package cn.com.guage.dtm.jubian;

import java.util.Scanner;

public class 找两倍数字2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        for (int i = 0; i < T; i++) {
            int n = scanner.nextInt();
            int[] numbers = new int[n];
            for (int j = 0; j < n; j++) {
                numbers[j] = scanner.nextInt();
            }
            int count = countPairs(numbers);
            System.out.println(count);
        }
        scanner.close();
    }

    public static int countPairs(int[] numbers) {
        int count = 0;
        for (int i = 0; i < numbers.length; i++) {
            for (int j = i + 1; j < numbers.length; j++) {
                if (numbers[i] * 2 == numbers[j] || numbers[j] * 2 == numbers[i]) {
                    count++;
                }
            }
        }
        return count;
    }
}    